package com.cz.thread;

import cn.hutool.core.thread.ThreadUtil;
import cn.hutool.http.HttpUtil;

import java.util.concurrent.ExecutorService;

public class ThreadTest {
    public static void main(String[] args) {
        singleThread();
    }

    public static void multiThread() {
        ExecutorService executor = ThreadUtil.newExecutor(10);
        for (int i = 0; i < 10; i++) {
            executor.execute(new Runnable() {
                public void run() {
                    String result = HttpUtil.get("http://localhost:9015/genCode");
                    System.out.println(result);
                }
            });
        }
        executor.shutdown();
    }

    public static void singleThread() {
        String result = HttpUtil.get("http://localhost:9015/genCode");
        System.out.println(result);

        String result1 = HttpUtil.get("http://localhost:9015/genCode");
        System.out.println(result1);
    }
}
